Add additional contextual information to invalid-style-prop warning#4482
Add additional contextual information to invalid-style-prop warning#4482niole wants to merge 13 commits intofacebook:masterfrom
Conversation
…that erroring element is a child of.
|
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla - and if you have received this in error or have any questions, please drop us a line at cla@fb.com. Thanks! |
|
This works in a live setting when inside of a working app. |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
There was a problem hiding this comment.
It's the style prop of the owner component? This doesn't look right to me. I don't think it's the "style prop of the owner"
There was a problem hiding this comment.
I read the issue as being it would be helpful if the error message
contained the name of the react class that has the render method where the
style prop has bad syntax, which is what that piece of code returns
On Jul 24, 2015 11:03 PM, "Jim" notifications@github.com wrote:
In src/renderers/dom/shared/ReactDOMComponent.js
#4482 (comment):@@ -263,7 +263,7 @@ function assertValidProps(component, props) {
}
invariant(
props.style == null || typeof props.style === 'object',
- 'The
styleprop expects a mapping from style properties to values, ' +- 'The
styleprop of '+component._currentElement._owner._instance.proto.constructor.displayName + ' expects a mapping from style properties to values, ' +It's the style prop of the owner component? This doesn't look right to me.
—
Reply to this email directly or view it on GitHub
https://github.com/facebook/react/pull/4482/files#r35480276.
There was a problem hiding this comment.
Woops must have been sleepy when I submitted that. I would change it to say
'check the render method of '+code_snippet
I read the issue as being it would be helpful if the error message
contained the name of the react class that has the render method where the
style prop has bad syntax, which is what that piece of code returns
On Jul 24, 2015 11:03 PM, "Jim" notifications@github.com wrote:
In src/renderers/dom/shared/ReactDOMComponent.js
#4482 (comment):@@ -263,7 +263,7 @@ function assertValidProps(component, props) {
}
invariant(
props.style == null || typeof props.style === 'object',
- 'The
styleprop expects a mapping from style properties to values, ' +- 'The
styleprop of '+component._currentElement._owner._instance.proto.constructor.displayName + ' expects a mapping from style properties to values, ' +It's the style prop of the owner component? This doesn't look right to me.
—
Reply to this email directly or view it on GitHub
https://github.com/facebook/react/pull/4482/files#r35480276.
There was a problem hiding this comment.
You need to have an if-check, because there is no guarantee that _owner isn't null (element could have been created outside of a render method), in which case this will throw.
…correct inline styling
There was a problem hiding this comment.
Add %s into the string here, then pass getDecl..() as a 3rd argument.
|
Should I add this prefix to the test and the actual code?
|
|
@niole No, just the test. The issue is that the actual code adds it automatically when you invoke invariant but the test does not. |
There was a problem hiding this comment.
You still have a leading space inside the text which doesn't belong. But do we really need this new sentence? I don't think it really adds anything and with the addendum we'll say to check the render method of a component.
|
Please run your tests locally before pushing. You can iterate much more quickly that way instead of waiting for travis to tell you there are failures. |
|
You can run your tests using If you read somewhere that you should use |
|
What's up with this eslint-plugin-react-internal and how do I get it?
|
|
|
There was a problem hiding this comment.
Please just leave the beginning of this message as it was. We really just need the addendum.
|
Sorry for the delay, GitHub doesn't send notifications when there are new / changed commits added. |
|
@zpao @jimfb how does it look? I'm also wondering about how to run tests locally. I upgraded npm and everything's installing.
should I use io.js? |
Add additional contextual information to invalid-style-prop warning
|
@zpao Thanks! On Thu, Aug 27, 2015 at 6:29 PM, Paul O’Shannessy notifications@github.com
|
inline style prop error thrown for JSX React elements now names React class that erroring element is a child of. Fixes #4168